home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / DropInfo ƒ / DI⁄C / DIUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-21  |  3.3 KB  |  156 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2. **
  3. **  Project Name:    DropInfo
  4. **     File Name:    DIUtils.c
  5. **
  6. **   Description:    Generic utility routines used by DropInfo
  7. **
  8. *******************************************************************************
  9. **                       A U T H O R   I D E N T I T Y
  10. *******************************************************************************
  11. **
  12. **    Initials    Name
  13. **    --------    -----------------------------------------------
  14. **    SCS            Stephan Somogyi
  15. **
  16. *******************************************************************************
  17. **                      R E V I S I O N   H I S T O R Y
  18. *******************************************************************************
  19. **
  20. **      Date        Time    Author    Description
  21. **    --------    -----    ------    ---------------------------------------------
  22. **    29.22.91            SCS        Original Version scavenged from MyMacStuff parts
  23. **
  24. ******************************************************************************/
  25.  
  26. #ifndef THINK_C
  27.     #define TRUE true
  28.     #define FALSE false
  29.  
  30.     #include <Dialogs.h>
  31.     #include <Controls.h>
  32.     #include <OSUtils.h>
  33. #endif
  34.  
  35. #include "DIUtils.h"
  36.  
  37.  
  38. /*    Flashes an item, in DropInfo's case a button, briefly. Used to show the
  39.     effect of a kbd-shortcut.
  40. */
  41. void
  42. FlashItem(DialogPtr pDial, short pItem)
  43. {
  44.     short            lType;
  45.     ControlHandle    lHndl;
  46.     Rect            lBox;
  47.     long            lDummy;
  48.  
  49.     GetDItem(pDial, pItem, &lType, (Handle *) &lHndl, &lBox);
  50.     if ((**lHndl).contrlHilite == 255)
  51.         return;
  52.     else    {
  53.         HiliteControl(lHndl, 1);
  54.         Delay(8, &lDummy);
  55.         HiliteControl(lHndl, 0);
  56.     }
  57. }
  58.  
  59.  
  60. /*    Disables or enables a item in a dialog box depending on the state of the
  61.     parameter "on".
  62. */
  63. void
  64. DisEnAble(DialogPtr dptr, short item, Boolean on)
  65. {
  66.     Rect    aRect;
  67.     short    iType;
  68.     Handle    iHndl;
  69.  
  70.     GetDItem(dptr, item, &iType, &iHndl, &aRect);
  71.     if (on == TRUE)
  72.         HiliteControl((ControlHandle) iHndl, 0);
  73.     else
  74.         HiliteControl((ControlHandle) iHndl, 255);
  75.  
  76. }
  77.  
  78.  
  79. /*    Checks or unchecks either a checkbox or a radio button depending on the
  80.     state of the parameter "on".
  81. */
  82. void
  83. CheckBox(DialogPtr dptr, short item, Boolean on)
  84. {
  85.     Rect    aRect;
  86.     short    iType;
  87.     Handle    iHndl;
  88.  
  89.     GetDItem(dptr, item, &iType, &iHndl, &aRect);
  90.     if (on == TRUE)
  91.         SetCtlValue((ControlHandle) iHndl, 1);
  92.     else
  93.         SetCtlValue((ControlHandle) iHndl, 0);
  94.  
  95. }    /* CheckBox */
  96.  
  97.  
  98. /*    Gets the contents of the dialog text item specified */
  99. void
  100. GetTxtItem(DialogPtr dptr, short item, Str255 *txt)
  101. {
  102.     Rect    aRect;
  103.     short    iType;
  104.     Handle    iHndl;
  105.  
  106.     GetDItem(dptr, item, &iType, &iHndl, &aRect);
  107. #ifndef THINK_C
  108.     GetIText(iHndl, (Str255) txt);
  109. #else
  110.     GetIText(iHndl, txt);
  111. #endif
  112.  
  113. }    // GetTxtItem// 
  114.  
  115.  
  116. /*    Sets the contents of the dialog text item specified */
  117. void
  118. SetTxtItem(DialogPtr dptr, short item, Str255 *txt)
  119. {
  120.     Rect    aRect;
  121.     short    iType;
  122.     Handle    iHndl;
  123.  
  124.     GetDItem(dptr, item, &iType, &iHndl, &aRect);
  125. #ifndef THINK_C
  126.     SetIText(iHndl, (Str255) txt);
  127. #else
  128.     SetIText(iHndl, txt);
  129. #endif
  130.  
  131. }    /* SetTxtItem */
  132.  
  133.  
  134. /*    Creates the standard outline around a dialog's default item    */
  135. void
  136. DefBut(DialogPtr dptr)
  137. {
  138.     Rect        aRect;
  139.     short        iType;
  140.     Handle        iHandle;
  141.     PenState    oldPen;
  142.     GrafPtr        Sherry;        /* old port */
  143.  
  144.  
  145.     GetPenState(&oldPen);
  146.     GetPort(&Sherry);
  147.     SetPort(dptr);
  148.     GetDItem(dptr, ((DialogPeek) dptr)->aDefItem, &iType, &iHandle, &aRect);
  149.     InsetRect(&aRect, -4, -4);
  150.     PenSize(3, 3);
  151.     FrameRoundRect(&aRect, 16, 16);
  152.     SetPort(Sherry);
  153.     SetPenState(&oldPen);
  154.  
  155. }    /* DefBut */
  156.